﻿package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import flash.external.ExternalInterface;
	
	public class Main extends Sprite
	{
		private var mainTracker:SWFTracker;
		public function Main():void
		{
			mainTracker = new SWFTracker();
			
			mainTracker.defineFunctionAlias("trace", traceHELLO);
			mainTracker.addEventListenersFromString('something', 'trace(dispatched by hand!)')
			
			mainTracker.run()
			
			stage.addEventListener(MouseEvent.CLICK, lCLICK);
		}
		
		private function lCLICK(e:MouseEvent):void {
			mainTracker.dispatchTrackerEvent('something')
		}

		private function traceHELLO(message:String):void {
			ExternalInterface.call("alert", message);
		}
		
	}
}